package com.itnoob.demo1;

import javax.websocket.PongMessage;

/**
 * 定义一个具体的访问者,实现Visitor方法,进行不同类型的商品进行积分兑换操作
 * @author zhoujun
 * @date 2025/3/26 21:08
 */
public class PointVisitor implements Visitor{

    private double pointRate;

    public PointVisitor(double pointRate) {
        this.pointRate = pointRate;
    }

    @Override
    public void visit(Product product) {
        //根据商品的价格和积分比率计算可兑换的积分,并打印结果
         double points = product.getPrice() * pointRate ;
        System.out.println(product.getType() + "可以兑换" + points + "的积分.");
    }
}
